package com.example.java8.forkJoin;

import java.time.Duration;
import java.time.Instant;
import java.time.temporal.TemporalUnit;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;

/**
 * 测试类
 *
 * @author qibao
 * @version v0.1 2020/12/17
 */
public class ForkJoinTest {
    public static void main(String[] args) {
        Instant start = Instant.now();
        ForkJoinPool forkJoinPool = new ForkJoinPool();
        ForkJoinTask<Long> forkJoinTask = new ForkJoinDemo(0L, 1000000L);
        Long res = forkJoinPool.invoke(forkJoinTask);
        System.out.println(res);

        Instant end = Instant.now();
        Long mid = Duration.between(start, end).toMillis();
        System.out.println("耗时：" + mid);
    }
}
